/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.cq.bd.service.impl;

import java.util.List;
import java.util.Map;

import com.cq.base.domain.Page;
import com.cq.bd.dao.SFunctionDao;
import com.cq.bd.dao.SFunctionResoDao;
import com.cq.bd.dao.jdbc.SFunctionJdbcDao;
import com.cq.bd.domain.SFunction;
import com.cq.bd.domain.SFunctionReso;
import com.cq.bd.service.FuncService;

/**
 * 权限管理服务
 * 
 * @author huangmy
 * @date   2009-10-5
 */
@SuppressWarnings("unchecked")
public class FuncServiceImpl implements FuncService {
    private SFunctionDao sFunctionDao;
    private SFunctionResoDao sFunctionResoDao;
    private SFunctionJdbcDao sFunctionJdbcDao;
        
    public List<SFunctionReso> doGetFuncResos(Long funcId) {
        return this.sFunctionResoDao.find("from SFunctionReso where funcId=?", funcId);
    }
    
    public List<SFunction> doGetSubFuncs(Long upperFuncId) {
        return this.sFunctionJdbcDao.getSubFuncs(upperFuncId);
    }
    
    public Page pageFuncs(Map<String, String> filter, Map<String, String> like, Map<String, String> sort, int pageNo,
            int pageSize) {
        return this.sFunctionDao.pagedQuery(filter, like, sort, pageNo, pageSize);
    }
    
    public void doChangeState(Long funcId, int state) {
        SFunction func = this.sFunctionDao.get(funcId);
        if (func != null) {
            func.setState(state);
            this.sFunctionDao.update(func);
        }
    }
    
    public SFunction doGetFunc(Long funcId) {
        return this.sFunctionDao.get(funcId);
    }
    
    public Long doCreateFunc(SFunction func) {
        return (Long)this.sFunctionDao.create(func);
    }

    public List<SFunction> doGetFuncs() {
        return this.sFunctionDao.list();
    }

    public void doUpdateFunc(SFunction func) {
        this.sFunctionDao.update(func);
    }
    
    public void doCreateFuncReso(SFunctionReso funcReso) {
        this.sFunctionResoDao.create(funcReso);
    }
    
    public void doRemoveFuncReso(SFunctionReso funcReso) {
        this.sFunctionResoDao.remove(funcReso);
    }

    public void setSFunctionDao(SFunctionDao functionDao) {
        this.sFunctionDao = functionDao;
    }

    public void setSFunctionResoDao(SFunctionResoDao functionResoDao) {
        this.sFunctionResoDao = functionResoDao;
    }

    public void setSFunctionJdbcDao(SFunctionJdbcDao functionJdbcDao) {
        sFunctionJdbcDao = functionJdbcDao;
    }

}
